package com.edu.app.controller.utils;

import com.edu.app.constant.SysMessage;
import com.edu.app.controller.utils.wx.Sign;
import com.edu.app.controller.utils.wx.WxUtils;
import com.edu.app.util.MsgUtil;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/utils")
@RestController
public class UtilsController {

    @GetMapping(value = "/getWxToken")
    public ModelMap getWxToken(@RequestParam String url){
        String appid = "wx60f5ca4182fe5223";
        String appsecret = "cfac17a6bbd7495d5705d0e315d0ed96";
        return Sign.getParam(appid, appsecret, url);
    }

    @GetMapping(value = "/getAppWxToken")
    public ModelMap getAppWxToken(@RequestParam String code){
        String appid = "wxb2751bb441fcef02";
        String appsecret = "9cb8b0852423a4c28d7aaffeb87ba94a";
        String accessToken = WxUtils.getAppAccess_token(appid, appsecret, code);
        return MsgUtil.retMsg(SysMessage.ADD_ACTIVITY_SUCCEED, "access_code", accessToken);
    }
}
